<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>event对象</title>
	</head>
	<body>
		<button>event对象</button>
		<script type="text/javascript">
			var btn1 = document.getElementsByTagName("button")[0];
			//谷歌ie8以上支持event对象
			btn1.onclick = function(){
				console.log(event);
			}
//			火狐支持传参
			btn1.onclick = function(e){
				console.log(e);
			}
			//兼容性写法 及鼠标位置
			btn1.onclick = function(e){
				var oEv = e || window.event;
				console.log("当前鼠标的位置"+oEv.clientX+","+oEv.clientY);
			}
			//兼容性写法 获取按钮
			document.onkeydown = function(e){
				var oEv = e || window.event;
				console.log("按得键的keycode是："+oEv.keyCode);
			}
		</script>
	</body>
</html>
